package com.jzo2o.foundations.controller.operation;


import com.jzo2o.common.model.PageResult;
import com.jzo2o.foundations.model.dto.request.ServePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeUpsertReqDTO;
import com.jzo2o.foundations.model.dto.response.RegionResDTO;
import com.jzo2o.foundations.model.dto.response.ServeResDTO;
import com.jzo2o.foundations.service.IRegionServiceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 赵超
 */
@RequiredArgsConstructor
@RestController
@Slf4j
@RequestMapping("/operation/serve")
@Api("服务管理")
public class RegionServiceController {

    private final IRegionServiceService regionServiceService;


    @ApiOperation(value = "服务管理分页查询")
    @GetMapping("/page")
    public PageResult<ServeResDTO> page(ServePageQueryReqDTO dto) {
        return regionServiceService.page(dto);
    }

    @ApiOperation(value = "服务管理新增服务")
    @PostMapping("/batch")
    public void batchAdd(@RequestBody List<ServeUpsertReqDTO> serveUpsertReqDTOList) {
        log.info("服务管理新增服务:{}", serveUpsertReqDTOList);
        regionServiceService.batchAdd(serveUpsertReqDTOList);
    }

    @ApiOperation(value = "服务管理删除服务")
    @DeleteMapping("/{id}")
    public void delete(@PathVariable("id") Long id) {
        regionServiceService.delete(id);
    }

    @ApiOperation(value = "服务管理修改价格")
    @PutMapping("/{id}")
    public void updatePrice(@PathVariable("id") Long id, @RequestParam("price") Double price) {
        regionServiceService.updatePrice(id, price);
    }

    @ApiOperation(value = "服务管理设置热门项目")
    @PutMapping("/onHot/{id}")
    public void updateOnHot(@PathVariable("id") Long id) {
        regionServiceService.updateOnHot(id);
    }

    @ApiOperation(value = "服务管理取消热门项目")
    @PutMapping("/offHot/{id}")
    public void updateOffHot(@PathVariable("id") Long id) {
        regionServiceService.updateOnHot(id);
    }

    @ApiOperation(value = "服务管理,项目上架")
    @PutMapping("/onSale/{id}")
    public void updateOnSale(@PathVariable("id") Long id) {
        regionServiceService.updateOnSale(id);
    }

    @ApiOperation(value = "服务管理,项目上架")
    @PutMapping("/offSale/{id}")
    public void updateOffSale(@PathVariable("id") Long id) {
        regionServiceService.updateOnSale(id);
    }
}
